﻿import pygame

class Scene(pygame.sprite.RenderPlain):
	
	def __init__(self,backSurface,objects):
		self.backSurface = backSurface				
		super(Scene,self).__init__()
		
		for obj in objects:
			self.__setattr__(obj.id,obj)
			self.add(obj)
		
	def get_size(self):
		return self.backSurface.get_size()
		
	def get_surface(self):
		return self.backSurface
	
	def draw(self):
		for spr,index in self.spritedict.items():
			if spr.is_visible():
				self.backSurface.blit( spr.image,spr.rect )
				
	def fireEvent(self,event):			
		for go in self.sprites():
			go.fireEvent(self,event)
		
	def loop_routine(self):
		pass
				
class GameObject(pygame.sprite.Sprite):
	
	def __init__(self,id,eventManager):
		self.id = id
		self.eventManager = eventManager
		
		self._is_visible = True
		self._is_active = True
		super(GameObject,self).__init__()
				
	def fireEvent(self,scene,event):
		self.eventManager.fireEvent(scene,self,event)	
	
	def is_visible(self):
		return self._is_visible
		
	def is_active(self):
		return self._is_active

		
class EventManager():

	def fireEvent(self,scene,go,event):
		pass

		